#ifndef _EDITORINSTANCE_
#define _EDITORINSTANCE_

#include <iostream>
#include <stdlib.h>
#include <deque>
#include "SFML/Graphics.hpp"
#include "Graphics/Graphics.hpp"
#include "Content/Map.hpp"
#include "Content/MapLoader.hpp"
#include "Graphics/Camera.hpp"
#include "Actions/Actions.hpp"
#include "EditorRegionManager.hpp"
#include "EditorEntity.hpp"

/** 
* This class represents an instance of a map being edited.
* Each map being edited in the editor is encapsulated in this class.
*/
class EditorInstance{
private:
    void calculateMapSize();
    
public:
    enum Tool{
        /** 
        * The brush allows you to draw sprites.
        */
        Brush, 
        /** 
        * The fill tool.
        */
        Fill,
        /** 
        * The marquee tool allows you to select areas on the map.
        */
        Marquee,
        /** 
        * The move tool allows you to move the marquee selection.
        */
        Move,
        /** 
        * Region definition, size and movement tool.
        */
        Region
    };

    /** 
    * Map open in this editor instance.
    */
    Map* map;

    /** 
    * Region manager of this instance.
    */
    EditorRegionManager* regionManager;
    
    /** 
    * The camera position of this instance.
    */
    Entity* cameraPosition;

    /** 
    * History of actions in this instance.
    */
    deque<BaseAction*> actionHistory;

    /** 
    * Redo history in this instance.
    */
    deque<BaseAction*> redoHistory;

    /** 
    * The selected tool in this instance.
    */
    Tool selectedTool;

    /** 
    * The source of movement of marquee tool.
    */
    sf::Rect<int> moveSource;

    /** 
    * The marquee tool size.
    */
    sf::Rect<int> marqueeTool;

    
    EditorInstance(Map* m);
    ~EditorInstance();
};

#endif